package ControlLayer;


import ModelLayer.AddressBook;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;


/**
 * The test class AddressCtrTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class AddressCtrTest
{
    private ControlLayer.AddressCtr addressC1;
    private AddressBook book;

    /**
     * Default constructor for test class AddressCtrTest
     */
    public AddressCtrTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        addressC1 = new ControlLayer.AddressCtr();
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void testCreatedPerson()
    {
        addressC1.createPerson(12345, "John", "Home", "9210", "Aalborg", "+455839432");
        assertEquals("John", addressC1.getPersonName(12345));
        assertEquals("Home", addressC1.getPersonAddress(12345));
        assertEquals("Aalborg", addressC1.getPersonCity(12345));
        assertEquals("+455839432", addressC1.getPersonPhone(12345));
        assertEquals("9210", addressC1.getPersonPostalCode(12345));
    }
 

      @Test
    public void testUpdatePerson()
    {
        addressC1.createPerson(69696, "John", "Home", "9210", "Aalborg", "+455839432");
        addressC1.updatePerson(69696, "Hans", "Denmark", "8900", "Copenhagen", "975123");
        assertEquals("Denmark", addressC1.getPersonAddress(69696));
        assertEquals("Copenhagen", addressC1.getPersonCity(69696));
        assertEquals("Hans", addressC1.getPersonName(69696));
        assertEquals("975123", addressC1.getPersonPhone(69696));
        assertEquals("8900", addressC1.getPersonPostalCode(69696));
    }
    
    @Test
    public void testDeletePerson()
    {
        addressC1.createPerson(54321, "John", "Home", "9210", "Aalborg", "+455839432");
        addressC1.deletePerson(54321);
        book = AddressBook.getAddressBook();;
        assertEquals(null, book.searchPerson(54321));
        
    }



  
}







